package com.example.jikeyoujikeyou.office_sz.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.jikeyoujikeyou.office_sz.R;


/**
 * Created by B-308 on 2017/11/28.
 */
public class TitleBar extends LinearLayout{
    Context context;
    ImageView iv_return, iv_setting;
    TextView tv_title, tv_setting;
//    ITitleListener iTitleListener;

    public ImageView getIv_return(){
        return iv_return;
    }
    public ImageView getIv_setting(){
        return iv_setting;
    }
    public TextView getTv_title(){
        return tv_title;
    }
    public TextView getTv_setting(){
        return tv_setting;
    }

    public TitleBar(Context context) {
        this(context,null);
        this.context = context;
    }



    public TitleBar(Context context, AttributeSet attrs) {

        this(context, attrs, 0);
        this.context = context;
    }



    public TitleBar(final Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        InitView(context);
        iv_return.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
//                if(null != iTitleListener)
//                    iTitleListener.onReturnClick();
            }
        });
        tv_setting.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
//                if(null != iTitleListener)
//                    iTitleListener.onSettingClick();
            }
        });
    }



    public void setIvReturn(int resource) {
        iv_return.setImageResource(resource);
    }

    public void setIvSetting(int resource) {
        iv_setting.setImageResource(resource);
    }

    public void setTitle(int textRes) {
        tv_title.setText(textRes);
    }

    public void setTitle(String text) {
        tv_title.setText(text);
    }

    public void setSetting(int textRes) {
        tv_setting.setText(textRes);
    }

    public void setSetting(String text) {
        tv_setting.setText(text);
    }

    private void InitView(Context context) {
        View view = View.inflate(context, R.layout.layout_titlebar,this);
        iv_return = (ImageView) view.findViewById(R.id.iv_return);
        iv_setting = (ImageView) view.findViewById(R.id.iv_setting);
        tv_setting = (TextView) view.findViewById(R.id.tv_setting);
        tv_title = (TextView) view.findViewById(R.id.tv_title);
    }

}
